home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Tools - Objects
/
MacsBug
/
MacsBug 6.2.1
/
dcmds
/
C Samples
/
Heap.c
< prev
next >
Wrap
Text File
|
1991-05-01
|
2KB
|
81 lines
/* Heap.c
The following MPW commands will build the dcmd and copy it to the
"Debugger Prefs" file in the System folder. The dcmd's name in
MacsBug will be the name of the file built by the Linker.
C Heap.c -b
Link {dcmdLib}dcmdGlue.a.o Heap.c.o {dcmdLib}DRuntime.o {CLibraries}StdCLib.o -o Heap
BuildDcmd Heap 100
Echo 'include "Heap";' | Rez -a -o "{systemFolder}Debugger Prefs"
*/
#include <Types.h>
#include "dcmd.h"
void NumberToHex (long number, Str255 hex)
{
Str255 digits = "0123456789ABCDEF";
int n;
strcpy (hex, &".00000000");
hex[0] = 8;
for (n = 8; n >= 1; n--)
{
hex[n] = digits[number % 16];
number = number / 16;
}
} // NumberToHex
pascal void DisplayBlockInfo (long blockAddress, long blockLength, long masterPtr, short blockType, Boolean locked, Boolean purgeable, Boolean resource)
{
Str255 value;
NumberToHex (blockAddress, value);
dcmdDrawLine (value);
NumberToHex (blockLength, value);
dcmdDrawString ("\p ");
dcmdDrawString (value);
if (blockType == relocatableBlock)
{
NumberToHex (masterPtr, value);
dcmdDrawString ("\p ");
dcmdDrawString (value);
dcmdDrawString ("\p ");
if (locked)
{ dcmdDrawString ("\pLocked "); }
if (purgeable)
{ dcmdDrawString ("\pPurgeable "); }
if (resource)
{ dcmdDrawString ("\pResource "); }
}
} // DisplayBlockInfo
pascal void CommandEntry (dcmdBlock* paramPtr)
{
switch (paramPtr->request)
{
case dcmdInit:
break;
case dcmdHelp:
dcmdDrawLine ("\pHEAP");
dcmdDrawLine ("\p Displays information about all heap blocks");
break;
case dcmdDoIt:
// Draw the column labels
dcmdDrawLine ("\p Address Length Mstr Ptr");
// The MacsBug heap iterator will call DisplayBlockInfo once for each block in the heap
dcmdForAllHeapBlocks (DisplayBlockInfo);
break;
}
} // CommandEntry